<?php


namespace app\api\controller\v1;


use app\common\controller\UserBaseController;
use app\common\library\dotgen;
use app\common\library\TimerALModel;
use app\common\library\CoordConv;

class ConfigController extends UserBaseController
{

    function directAction()
    {
        $this->paramlist = array(
            'version' => 'optstring',
        );

        $this->check_params();

        $direct = [
            "no_park_area_type_enum" => [
                'ZHU_ZHAI_LOU' => '住宅楼',
                'XIE_ZI_LOU' => '写字楼',
                'XUE_XIAO' => '学校',
            ],
            "park_type_enum" => [
                'ZHU_ZHAI_LOU' => '住宅楼',
                'XIE_ZI_LOU' => '写字楼',
                'SCHOOL' => '学校',
            ],
            'warehouse_purpose_type_num' => [
                'ZONG_HE' => '综合',
                'WEI_XIU_BU' => '维修部',
            ],
            'warehouse_entity_type_num' => [
                'SHI_TI_CANG' => '物理仓',
                'XU_NI_CANG' => '虚拟仓',
            ],
            'bike_model_enum' => [
                'Q5' => 'Q5'
            ],
            'report_fault_type_enum' => [
                BIKE_FAULT_TYPE_CHE_DENG => '车灯',
                BIKE_FAULT_TYPE_XIAN_LU => '线路',
                BIKE_FAULT_TYPE_SHA_CHE => '刹车',
                BIKE_FAULT_TYPE_JIAO_DENG => '脚蹬',
                BIKE_FAULT_TYPE_CHE_ZUO => '车座',
                BIKE_FAULT_TYPE_GAI_BAN_KA_SI => '盖板卡死',
                BIKE_FAULT_TYPE_NING_BA_BU_ZOU => '拧把不走',
                BIKE_FAULT_TYPE_WU_FA_KAI_SUO => '无法开锁',
                BIKE_FAULT_TYPE_ER_WEI_MA => '二维码损坏',
                BIKE_FAULT_TYPE_ZHA_SUO => '闸锁',
                BIKE_FAULT_TYPE_LA_BA => '喇叭',
                BIKE_FAULT_TYPE_GUANG_GAO_PAI => '广告牌',
                BIKE_FAULT_TYPE_OTHER => '其他',
            ],
            'actual_fault_type_enum' => [
                BIKE_FAULT_TYPE_X_KONG_ZHI_QI => '控制器',
                BIKE_FAULT_TYPE_X_DIAN_JI => '电机',
                BIKE_FAULT_TYPE_X_SHA_CHE => '刹车',
            ],
            'actual_fault_subtype_enum' => [
                BIKE_FAULT_TYPE_X_KONG_ZHI_QI => [
                    BIKE_FAULT_TYPE_X_KONG_ZHI_QI_JIN_SHUI_DUAN_LU => '控制器故障,进水短路',
                    BIKE_FAULT_TYPE_X_KONG_ZHI_QI_GONG_NENG => '控制器故障, 功能故障',
                ],
                BIKE_FAULT_TYPE_X_DIAN_JI => [
                    BIKE_FAULT_TYPE_X_DIAN_JI_XIAN_LU => '电机故障,线路故障',
                    BIKE_FAULT_TYPE_X_DIAN_JI_GAI_LIE => '电机故障,盖子裂了',
                    BIKE_FAULT_TYPE_X_DIAN_JI_GONG_NENG => '电机故障, 功能故障',
                ],
                BIKE_FAULT_TYPE_X_SHA_CHE => [
                    BIKE_FAULT_TYPE_X_SHA_CHE_QIAN => '刹车-前刹',
                    BIKE_FAULT_TYPE_X_SHA_CHE_HOU => '刹车-后刹',
                    BIKE_FAULT_TYPE_X_SHA_CHE_XIAN => '刹车-莎车县',
                    BIKE_FAULT_TYPE_X_SHA_CHE_DIAO_JIE => '刹车-不能调节',
                ],
            ],
            'staff_position_enum' => [
                'BOSS' => '老板',
                'MANAGER' => '经理',
            ],
            'adjust_amount_type_num' => [
                1 => '未定义的费用',
                99 => ' 其他',
            ],
            'res_server_url' => 'https://res.ddebike.com',
            'bike_bus_state_enum' => [
                BIKE_BUS_STAT_IDLE => '空闲',
                BIKE_BUS_STAT_RESERVED => '用户骑行-预约',
                BIKE_BUS_STAT_RIDING => '用户骑行-骑行中',
                BIKE_BUS_STAT_TEMP_PARK => '用户骑行-临时锁车',
                BIKE_BUS_STAT_OPER_REPARK => '运维挪车',
                BIKE_BUS_STAT_BATTERY_CHANGE => '运维换电',
            ],
            'version' => '1.0.0',
            'mt' => \common::get_may_amount(),
        ];
        if (isset($this->argv['version']) && $this->argv['version'] == '1.0.71') {
            $direct['version'] = 'VERSION_FOR_AUDIT';
        }
        $this->resp['direct'] = $direct;

        return $this->ret_resp();
    }

    function wxmpenvAction()
    {
        //TimerALModel::instance()->call_bus_server('config/test1', [], 0);


        $f = 'HTTP_REFERER';
//        if (isset($_SERVER[$f])) {
//            $f = $_SERVER[$f];
//        }

        $f = $this->request->server('HTTP_REFERER');
        if (empty($f)){
            $f = 'HTTP_REFERER';
        }
        //hilog::debug('wxmpenv ref', $_SERVER);
        //  $f = "https://servicewechat.com/adfasfdasdf/devtool/index.html";
        // $f = 'https://servicewechat.com/wx8bf4994e6cf0d0d7/devtools/page-frame.html';
        $p = '/^https:\/\/(?:[0-9a-zA-Z-.]*)\/(?:[a-z0-9A-Z]*)\/([a-z0-9A-Z]*)\/(?:.*)$/';
        $matches = [];
        preg_match($p, $f, $matches);

        $dev = 'other';
        if (count($matches) >= 2) {
            $dev = $matches[1];
        }
        if ($dev == 'devtools') {
            $dev = 'devtools';
        } else if ($dev == '0') {
            $dev = 'exp';
        } else if ($dev == '1') {
            $dev = 'online';
        }

        $this->resp['env'] = $dev;
        $this->resp['env_desc'] = '[其他, 开发工具, 体验版, 正式版]';
        $this->resp['env_num'] = '[other, devtools, exp, online]';

        return $this->ret_resp();
    }

    function testAction()
    {
        $park_time = strtotime('2019-09-06 03:18:58');
        $now =  strtotime('2019-09-06 10:10:10');
        $now_time_h = date('H', $now);
        $dif = floor(($now - $park_time) / 86400);

        $repark_index = 0;
        $repark_index += $dif * 18;
        $park_time_h = date('H', $park_time);
        $s = $park_time_h;
        $e = $now_time_h;
        if ($e < $s) {
            $e = $e + 24;
        }
        echo $s . "##" . $e;
        for ($i = $s; $i < $e; $i++) {
            $h = $i % 24;
            if ($h < 7 || $h > 21) {
                $repark_index += 0;
            } else {
                $repark_index += 1;
            }
        }

        $park_state = 0;
        $c = 1;
        if ($park_state == BIKE_PARK_STAT_OSA) {
            if ($repark_index <= 0) {
                $repark_index = 1;
            }
            $c = 5;
        } else if ($park_state == BIKE_PARK_STAT_NPA) {
            if ($repark_index <= 0) {
                $repark_index = 1;
            }
            $c = 3;
        } else if ($park_state == BIKE_PARK_STAT_PARK) {
            $repark_index = 0;
        }
        $repark_index *= $c;

        // hilog::debug("############## {$bike_info['id']}, repark_index={$repark_index}");
        $repark_index = floor($repark_index / 3);
        if ($repark_index > 4) {
            $repark_index = 4;
        }

        $this->resp['repark_index'] = $repark_index;
        $this->resp['nowtime'] = date('Y-m-d H:i:s');
        //sleep(rand(0, 20));

        return $this->ret_resp();
    }

    function timer_testAction()
    {
        for ($i = 0; $i < 100; $i++) {

            $timeout = rand(0, 20);
            $params = [
                'ctx' => 1000000 + $i,
                'deadline' => date('Y-m-d H:i:s', time() + $timeout),
            ];

            TimerALModel::instance()->call_bus_server("/config/test", $params, $timeout);
        }

        return $this->ret_resp();

    }

    function user_configAction()
    {
        $cfg = [
            'hotline' => '4008208820',
        ];
        $this->resp['config'] = $cfg;

        return $this->ret_resp();
    }

    function distanceAction()
    {
        $this->paramlist = [
            'A' => 'coordinate',
            'B' => 'coordinate',
        ];
        $this->check_params();


        $this->resp['distance'] = \common::distance($this->argv['A'], $this->argv['B']);

        return $this->ret_resp();
    }

    function gpsAction()
    {
        $this->paramlist = [
            'lon' => 'string',
            'lat' => 'string',
        ];
        $this->check_params();

        $coordinate = (new CoordConv())->wgs84togcj02([$this->argv['lon'], $this->argv['lat']]);
        $this->resp['coordinate'] =$coordinate;

        return $this->ret_resp();
    }

    public function test_strAction()
    {
        $content = "{\"status\":0,\"list\":{\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"6760Q8R6FILY\",\"id\":\"ZGAGZQ8MBHD6\",\"lastname\":\"\u90b1\",\"firstname\":\"\u9429\",\"name\":\"\u90b1\u9429\",\"alive\":0,\"zi\":\"\u5b54\u660e\",\"hao\":\"\",\"born_rank_gender\":1,\"born_rank\":2,\"generation\":11,\"gender\":1,\"kin_type\":1,\"kin_status\":0,\"bound_user_wx_avatar\":null,\"authed\":1,\"marriages\":[{\"spouse\":[],\"children\":[{\"generation\":12,\"born_rank\":1,\"firstname\":\"\u6ecb\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"ZGAGZQ8MBHD6\",\"zi\":\"\u672c\u6da6\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u6ecb\",\"id\":\"FD1JBSSVU103\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":12,\"born_rank\":1,\"firstname\":\"\u6797\u798f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u6797\u798f\",\"kin_type\":10,\"id\":\"4I0LDNUPQO1B\",\"authed\":1},\"children\":[{\"generation\":13,\"born_rank\":1,\"firstname\":\"\u6821\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\u5ef7\u5b66\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u6821\",\"id\":\"WWB07Z2GJR63\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":13,\"born_rank\":1,\"firstname\":\"\u6b27\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u6b27\u6c0f\",\"kin_type\":10,\"id\":\"0PGDEXXX9402\",\"authed\":1},\"children\":[{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u708e\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\u4e16\u84b8\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u708e\",\"id\":\"0T6OES7PWRHI\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u4e01\u51c0\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"0T6OES7PWRHI\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u4e01\u51c0\",\"kin_type\":10,\"id\":\"RP8140ATVOPF\",\"authed\":1},\"children\":[{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u57f9\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"0T6OES7PWRHI\",\"zi\":\"\u826f\u679d\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u57f9\",\"id\":\"WFVSQUTUON8Z\",\"kin_type\":1,\"authed\":1,\"marriages\":[]}]},{\"spouse\":{\"generation\":14,\"born_rank\":2,\"firstname\":\"\u6768\u69d0\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"0T6OES7PWRHI\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u6768\u69d0\",\"kin_type\":10,\"id\":\"ZAJYTL8SP1S5\",\"authed\":1},\"children\":[]},{\"spouse\":{\"generation\":14,\"born_rank\":3,\"firstname\":\"\u90d1\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"0T6OES7PWRHI\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u90d1\u6c0f\",\"kin_type\":10,\"id\":\"0L607GBXD0O2\",\"authed\":1},\"children\":[]}]},{\"generation\":14,\"born_rank\":2,\"firstname\":\"\u70a4\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\u4e16\u9451\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u70a4\",\"id\":\"6W32S9F3A50C\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u738b\u957f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"6W32S9F3A50C\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u738b\u957f\",\"kin_type\":10,\"id\":\"A2PLTI8PERZZ\",\"authed\":1},\"children\":[]}]},{\"generation\":14,\"born_rank\":3,\"firstname\":\"\u3db4\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\u4e16\u9526\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u3db4\",\"id\":\"M3GCE2Q24TCU\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u9648\u95f0\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"M3GCE2Q24TCU\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9648\u95f0\",\"kin_type\":10,\"id\":\"R9G3ZRYMKLVI\",\"authed\":1},\"children\":[{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u57d9\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"M3GCE2Q24TCU\",\"zi\":\"\u826f\u5668\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u57d9\",\"id\":\"CWCQ2UYVW9HI\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u9ec4\u6d01\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9ec4\u6d01\",\"kin_type\":10,\"id\":\"MRECD3Y10BM7\",\"authed\":1},\"children\":[{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u5e94\u673a\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"zi\":\"\u5fb7\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u673a\",\"kin_type\":1,\"id\":\"307ZVTM30L7A\",\"authed\":1,\"marriages\":[]},{\"generation\":16,\"born_rank\":2,\"firstname\":\"\u5e94\u79fd\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"zi\":\"\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u79fd\",\"kin_type\":1,\"id\":\"MKPF90QYQPHA\",\"authed\":1,\"marriages\":[]},{\"generation\":16,\"born_rank\":3,\"firstname\":\"\u5e94\u9e92\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"zi\":\"\u5fb3\u7ae0\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u9e92\",\"kin_type\":1,\"id\":\"ESOV4LCTQ8C1\",\"authed\":1,\"marriages\":[]},{\"generation\":16,\"born_rank\":4,\"firstname\":\"\u5e94\u9e9f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"zi\":\"\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u9e9f\",\"kin_type\":1,\"id\":\"NYB6EEJTGHWK\",\"authed\":1,\"marriages\":[]},{\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CWCQ2UYVW9HI\",\"id\":\"X5CSSK6IODZM\",\"lastname\":\"\u90b1\",\"firstname\":\"\u5e94\u91d1\",\"idcno\":null,\"name\":\"\u90b1\u5e94\u91d1\",\"wx_open_id\":null,\"wx_union_id\":null,\"wx_avatar_url\":null,\"alive\":0,\"phone\":null,\"birthdate_solar\":\"\",\"birthtime_solar\":\"\",\"birthdate_lunar\":\"\",\"birthtime_lunar\":\"\",\"zi\":\"\u5fb7\",\"hao\":\"\",\"sihao\":null,\"alias\":\"\",\"native_place\":\"\",\"born_rank_gender\":1,\"born_rank\":5,\"brief\":\"\u5b57\u5fb7  \uff0c\u884c\u4e09\u767e\u516b\u5341\u56db\u3002\u59a3\u4f55\u7389\u8471\u3002\u7ee7\u59a3\u90d1\u6c0f\u3002\u518d\u59a3\u9648\u65b9\uff0c\u751f\u5352\u846c\u5931\u8003\u3002 \u5b50\u4e00\uff1a\u534e\u6625\u3002\",\"deathdate_solar\":null,\"deathtime_solar\":null,\"deathdate_lunar\":null,\"deathtime_lunar\":null,\"generation\":16,\"gender\":1,\"shadowof\":null,\"bloodline\":1,\"father_id\":\"CWCQ2UYVW9HI\",\"father_name\":\"\u90b1\u57d9\",\"mother_id\":\"MRECD3Y10BM7\",\"mother_name\":\"\u9ec4\u6d01\",\"spouse_id\":\"S9DT720MIA82\",\"spouse_name\":\"\u90d1\u6c0f\",\"kin_type\":1,\"kin_status\":0,\"bound_user_id\":null,\"bound_user_wx_avatar\":null,\"bound_user_wx_nickname\":null,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u4f55\u7389\u8471\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X5CSSK6IODZM\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u4f55\u7389\u8471\",\"kin_type\":10,\"id\":\"YDN6BA77K0IL\",\"authed\":1},\"children\":[{\"generation\":17,\"born_rank\":1,\"firstname\":\"\u534e\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X5CSSK6IODZM\",\"zi\":\"\u65e5\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u534e\u6625\",\"kin_type\":1,\"id\":\"9RHRRV221IDJ\",\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":17,\"born_rank\":1,\"firstname\":\"\u90d1\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"9RHRRV221IDJ\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u90d1\u6c0f\",\"kin_type\":10,\"id\":\"591M79T8HR85\",\"authed\":1},\"children\":[{\"generation\":18,\"born_rank\":1,\"firstname\":\"\u5efa\u52cb\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"9RHRRV221IDJ\",\"zi\":\"\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5efa\u52cb\",\"kin_type\":1,\"id\":\"CPBQHG1CC3RL\",\"authed\":1,\"marriages\":[]}]}]}]},{\"spouse\":{\"generation\":16,\"born_rank\":2,\"firstname\":\"\u90d1\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X5CSSK6IODZM\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u90d1\u6c0f\",\"kin_type\":10,\"id\":\"S9DT720MIA82\",\"authed\":1},\"children\":[]},{\"spouse\":{\"generation\":16,\"born_rank\":3,\"firstname\":\"\u9648\u65b9\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X5CSSK6IODZM\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9648\u65b9\",\"kin_type\":10,\"id\":\"U5QMQ33VUA6X\",\"authed\":1},\"children\":[]}]}]}]},{\"generation\":15,\"born_rank\":2,\"firstname\":\"\u5880\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"M3GCE2Q24TCU\",\"zi\":\"\u826f\u537f\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5880\",\"id\":\"1BCKOH14NTEM\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u53f6\u7ea2\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"1BCKOH14NTEM\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u53f6\u7ea2\",\"kin_type\":10,\"id\":\"TMT6QEM5LM1N\",\"authed\":1},\"children\":[{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u5e94\u9e11\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"1BCKOH14NTEM\",\"zi\":\"\u5fb7\u85a6\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u9e11\",\"kin_type\":1,\"id\":\"3KSG74V7S3CO\",\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u5434\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"3KSG74V7S3CO\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u5434\u6c0f\",\"kin_type\":10,\"id\":\"957J38TGP8LJ\",\"authed\":1},\"children\":[{\"generation\":17,\"born_rank\":1,\"firstname\":\"\u9633\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"3KSG74V7S3CO\",\"zi\":\"\u65e5\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u9633\u6625\",\"kin_type\":1,\"id\":\"UZYJEW6AOXXF\",\"authed\":1,\"marriages\":[]}]},{\"spouse\":{\"generation\":16,\"born_rank\":2,\"firstname\":\"\u90d1\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"3KSG74V7S3CO\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u90d1\u6c0f\",\"kin_type\":10,\"id\":\"7BKI4VS0AX02\",\"authed\":1},\"children\":[]},{\"spouse\":{\"generation\":16,\"born_rank\":3,\"firstname\":\"\u9648\u6c0f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"3KSG74V7S3CO\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9648\u6c0f\",\"kin_type\":10,\"id\":\"5EJ7LZDXRKBZ\",\"authed\":1},\"children\":[]}]},{\"generation\":16,\"born_rank\":2,\"firstname\":\"\u5e94\u9e1e\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"1BCKOH14NTEM\",\"zi\":\"\u5fb7\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u9e1e\",\"kin_type\":1,\"id\":\"LKBEKKUHCU83\",\"authed\":1,\"marriages\":[]},{\"generation\":16,\"born_rank\":3,\"firstname\":\"\u5e94\u9e3f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"1BCKOH14NTEM\",\"zi\":\"\u5fb7\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u9e3f\",\"kin_type\":1,\"id\":\"I33B7DPHUENH\",\"authed\":1,\"marriages\":[]}]}]},{\"generation\":15,\"born_rank\":3,\"firstname\":\"\u575a\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"M3GCE2Q24TCU\",\"zi\":\"\u826f\u4ecb\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u575a\",\"id\":\"8RO3A7BSV9UZ\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u5434\u7eee\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"8RO3A7BSV9UZ\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u5434\u7eee\",\"kin_type\":10,\"id\":\"T68KIESF02V4\",\"authed\":1},\"children\":[{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u5e94\u8302\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"8RO3A7BSV9UZ\",\"zi\":\"\u5fb7\u79c0\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5e94\u8302\",\"kin_type\":1,\"id\":\"DW3SJ7L30IV1\",\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":16,\"born_rank\":1,\"firstname\":\"\u738b\u7389\u5170\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"DW3SJ7L30IV1\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u738b\u7389\u5170\",\"kin_type\":10,\"id\":\"7WMT1IIUXZLZ\",\"authed\":1},\"children\":[{\"generation\":17,\"born_rank\":1,\"firstname\":\"\u8fce\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"DW3SJ7L30IV1\",\"zi\":\"\u65e5\u8fdb\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u8fce\u6625\",\"kin_type\":1,\"id\":\"U8YI2B0RO1I4\",\"authed\":1,\"marriages\":[]},{\"generation\":17,\"born_rank\":2,\"firstname\":\"\u4e07\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"DW3SJ7L30IV1\",\"zi\":\"\u65e5\u6c38\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u4e07\u6625\",\"kin_type\":1,\"id\":\"UUKO4SP5X9LM\",\"authed\":1,\"marriages\":[]},{\"generation\":17,\"born_rank\":3,\"firstname\":\"\u56de\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"DW3SJ7L30IV1\",\"zi\":\"\u65e5\u743c\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u56de\u6625\",\"kin_type\":1,\"id\":\"GYLV8KY2NB24\",\"authed\":1,\"marriages\":[]},{\"generation\":17,\"born_rank\":4,\"firstname\":\"\u540c\u6625\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"DW3SJ7L30IV1\",\"zi\":\"\u65e5\u9f50\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u540c\u6625\",\"kin_type\":1,\"id\":\"Z78WR58TC72C\",\"authed\":1,\"marriages\":[]}]}]}]}]},{\"generation\":15,\"born_rank\":4,\"firstname\":\"\u578d\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"M3GCE2Q24TCU\",\"zi\":\"\u826f\u6574\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u578d\",\"id\":\"G48ZZRRV5V6Q\",\"kin_type\":1,\"authed\":1,\"marriages\":[]}]}]},{\"generation\":14,\"born_rank\":4,\"firstname\":\"\u70c8\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\u4e16\u5a01\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u70c8\",\"id\":\"X8BEEXEU12HF\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u90d1\u6df3\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X8BEEXEU12HF\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u90d1\u6df3\",\"kin_type\":10,\"id\":\"A3AF7OKW9FOO\",\"authed\":1},\"children\":[{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u5802\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"X8BEEXEU12HF\",\"zi\":\"\u826f\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5802\",\"id\":\"EQO0O16UV2VY\",\"kin_type\":1,\"authed\":1,\"marriages\":[]}]}]},{\"generation\":14,\"born_rank\":5,\"firstname\":\"\u7fb9\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"WWB07Z2GJR63\",\"zi\":\"\u4e16\u8fdb\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u7fb9\",\"id\":\"CUJ9CD5XIPS0\",\"kin_type\":1,\"authed\":1,\"marriages\":[{\"spouse\":{\"generation\":14,\"born_rank\":1,\"firstname\":\"\u9ec4\u84cb\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CUJ9CD5XIPS0\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9ec4\u84cb\",\"kin_type\":10,\"id\":\"IHBHPWYRLVJO\",\"authed\":1},\"children\":[{\"generation\":15,\"born_rank\":1,\"firstname\":\"\u5889\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CUJ9CD5XIPS0\",\"zi\":\"\u826f\u5f3c\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u5889\",\"id\":\"W7NYLUHMWPOX\",\"kin_type\":1,\"authed\":1,\"marriages\":[]}]},{\"spouse\":{\"generation\":14,\"born_rank\":2,\"firstname\":\"\u738b\u826f\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"CUJ9CD5XIPS0\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u738b\u826f\",\"kin_type\":10,\"id\":\"FGJT6LCWX3AQ\",\"authed\":1},\"children\":[]}]}]}]},{\"generation\":13,\"born_rank\":2,\"firstname\":\"\u6893\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\u5ef7\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u6893\",\"id\":\"CJR6WW9JEGZX\",\"kin_type\":1,\"authed\":1,\"marriages\":[]},{\"generation\":13,\"born_rank\":3,\"firstname\":\"\u6977\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\u5ef7\u7acb\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u6977\",\"id\":\"NFYWFTGU90SQ\",\"kin_type\":1,\"authed\":1,\"marriages\":[]},{\"generation\":13,\"born_rank\":4,\"firstname\":\"\u6797\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":1,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\u5ef7\u5415\",\"lastname\":\"\u90b1\",\"hao\":\"\",\"name\":\"\u90b1\u6797\",\"id\":\"RCSTO3HYZTU7\",\"kin_type\":1,\"authed\":1,\"marriages\":[]}]},{\"spouse\":{\"generation\":12,\"born_rank\":2,\"firstname\":\"\u9648\u4f5b\",\"kin_status\":0,\"born_rank_gender\":1,\"gender\":0,\"alive\":0,\"tree_id\":\"6I1ZW6UMVYUX\",\"pid\":\"FD1JBSSVU103\",\"zi\":\"\",\"lastname\":\"\",\"hao\":\"\",\"name\":\"\u9648\u4f5b\",\"kin_type\":10,\"id\":\"RU20IZQGRPJQ\",\"authed\":1},\"children\":[]}]}]}]}}";

        $data = json_decode($content,true);

        //return json($data);

        $dot = new dotgen($data['list']);
        $dot->save_plantuml();

        dump($dot);
        //return json($dot->generate_png());
    }
}
